<!DOCTYPE html>
<html style="width: 100%; height: 100%;">
<head lang="en">
    <meta charset="UTF-8">
    <title>内蒙古移动后台登陆</title>
    <link type="text/css" rel="stylesheet" href="/resources/easyui/themes/default/easyui.css">
    <link type="text/css" rel="stylesheet" href="/resources/easyui/themes/color.css">
    <link type="text/css" rel="stylesheet" href="/resources/easyui/themes/icon.css">
    <script type="text/javascript" src="/resources/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/resources/easyui/jquery.encoding.js"></script>
    <script type="text/javascript" src="/resources/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/resources/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/resources/easyui/plugin/jquery.cookie.js"></script>
    <script type="text/javascript" src="/resources/js/Util.js"></script>
</head>
<body style="width: 100%; height: 100%; background:#0a76b0;" onload="cleanCookie();">
<div id="loginWin" class="easyui-window" title="内蒙微信后台管理中心" minimizable="false" maximizable="false"
     resizable="false" collapsible="false" closable="false"
     style="width:380px;height:230px;padding:5px;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="padding-left: 30px;">
            <form id="loginForm" method="post">
                <div style="padding:5px 0;">
                    <label for="userName">用户名:</label>
                    <input id="userName" type="text" name="userName" class="easyui-validatebox easyui-textbox"
                           data-options="required:true,iconCls:'icon-man',iconAlign:'left',missingMessage:'该输入项为必输项'"/>
                </div>
                <div style="padding:5px 0;">
                    <label for="password">密&nbsp;&nbsp;码:</label>
                    <input id="password" type="password" name="password" class="easyui-validatebox easyui-textbox"
                           data-options="required:true,iconCls:'icon-lock',iconAlign:'left',missingMessage:'该输入项为必输项'"/>
                </div>
                <div style="padding:5px 0;">
                    <label for="code">验证码:</label>
                    <input id="code" type="text" name="code" class="easyui-validatebox easyui-textbox"
                           data-options="required:true,iconAlign:'left',missingMessage:'该输入项为必输项'"/>
                </div>
                <div style="padding:1px 48px;">
                    <img src="getcaptcha.sl" id="codeImg" onclick="document.getElementById('codeImg').src='getcaptcha.sl?temp='+ (new Date().getTime().toString(36)); return false;" style="cursor: pointer; margin-bottom: -7px;" alt="看不清楚,换一张">
                </div>
            </form>
        </div>
        <div region="south" border="false" style="text-align:right;padding:5px 0;">
            <a class="easyui-linkbutton" iconCls="icon-ok" onclick="login()">登录</a>
            <a class="easyui-linkbutton" iconCls="icon-cancel" onclick="clearData()">重置</a>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    document.onkeydown = function (e) {
        var event = e || window.event;
        var code = event.keyCode || event.which || event.charCode;
        if (code == 13) {
            login();
        }
    };
    function clearData() {
        $('#loginForm').form('clear');
    }
    function login() {
        var psd = $('#password').textbox("getValue");
        psd = $.encoding.digests.hexSha1Str(psd);
        $('#password').textbox("setValue", psd);
        restClient('/rest/admin/login', function(data){
            if (data.success){
                $.cookie("sessionId", data.data, {expires:1});
                location.href = 'main.html';
            } else {
                var message = data.message;
                if(data.subErrors && data.subErrors[0]) {
                    message = data.subErrors[0].message;
                }
                $.messager.show({
                    title:'温馨提示',
                    msg:message
                });
            }
        }, $('#loginForm').serialize());
    }
</script>
</html>